<!--
auth：zhanghaowei
email：66963858@qq.com
date：2022/11/21

1、设计值没有绘制对应的查看表，本功能完成之后，暂时通过角色权限，去掉查看按钮
2、本功能目前不正确，如需使用请修改loadReportList()方法
-->
<template>
  <div>
    <div class="page-title-wrapper">
      <div class="page-title">
        <h3>设计值配置</h3>
      </div>
      <div>
        <Button @click="handleBackClick">返回</Button>
        <Button  @click="printReport" ghost type="primary" class="btnstye">打印</Button>
        <Button  @click="exportReport(true)" ghost type="primary">导出Pdf</Button>
        <Button  @click="exportReport(false)" ghost type="primary" class="btnstye1">导出Excel</Button>
      </div>
    </div>
    <!-- style="height:100%;position:relative" -->
    <section>
      <div>
        <iframe
          :src="src"
          frameborder="0"
          id="iframe"
          scrolling="no"
          name='report'
          @load="loadFrame"
          style="border:none;width:100%;height:612px"
        ></iframe>
      </div>
    </section>
  </div>
</template>

<script>
import { tableRequestHeader } from '@/api/manage-design-value.js';
import { mixOutput } from '@/libs/mixin.js';

export default {
  components: {},
  mixins: [mixOutput],
  data () {
    return {
      filename: '',
      src: '',
      nodeId: '',
      theaderObj: {
        h1: '',
        h2: '',
        htdpart: '',
        qqzhNumber: ''
      }
    };
  },
  mounted () {
    this.loadReportList();
  },
  methods: {
    loadFrame () {
    },
    handleBackClick () {
      this.$router.go(-1);
    },

    // 报表头和报表url
    async loadReportList () {
      try {
        const param = this.$route.query;
        const resp = await tableRequestHeader({
          'nodeId': param.nodeId,
          'reportId': param.reportId
        });
        let respData = resp.data;
        if (respData.code != 200) {
          this.$Message.error(respData.msg);
          return;
        }

        console.log('respData=', respData);
        const { reportName, projectName, htdName, qqzh,
          token, filename, dataId, nodeId, url } = respData.data;

        this.theaderObj.h1 = reportName;
        this.theaderObj.h2 = projectName;
        this.theaderObj.htdpart = htdName;
        this.theaderObj.qqzhNumber = qqzh || '-';

        if (filename.includes('pingdingshi')) {
          // arg1 = 当前表的此条数据id
          // display = 控制表头表尾是否显示
          // fenxiang_id = 分项节点ID
          // fullcode = 分项编号
          // reportId = 为当前表在mysql中表中report_config配置的id
          // scale = 控制页面缩放比例
          // token = 用来重定向
          this.src = `${url}showReport.jsp?rpx=/view/${filename}.rpx&arg1=93&token=${token}&display=1&fenxiang_id=1843&fullcode=QXQ1L0102002&reportId=1979&scale=1.3`;
        } else if (filename.includes('view') && !filename.includes('zu')) {
          // arg1 = 当前表的此条数据id
          // pid = 1560,96 用,好合并两个值:->其中1560为工序id, 96为当前表在mysql中表中report_config配置的id
          // tid = 默认1
          this.src = `${url}showReport.jsp?rpx=/view/${filename}.rpx&arg1=47&pid=1560,96&token=${token}&tid=1`;
        } else {
          // arg1 = 当前表的此条数据id
          // pid = 1560,96 用,好合并两个值:->其中1560为工序id, 96为当前表在mysql中表中report_config配置的id
          // tid = 默认1
          this.src = `${url}showReportGroup.jsp?rpg=/view/qiaoshi_11_zu.rpg&arg1=35&pid=1857,94&token=${token}&tid=1`;
        }
        console.log(this.src);

        this.output = { filename, dataId, nodeId };// 导出，打印整理数据格式
      } catch (error) {
        console.error(error);
      }
    }

  }
};
</script>

<style lang="less" scoped>
.main .content-wrapper {
  overflow-x: hidden;
}
.page-title-wrapper {
  display: flex;
  justify-content: space-between;
  align-content: center;
  margin-bottom: 20px;
  .ivu-btn {
    margin-left: 20px;
  }
}
.borderRight{
  display:none;
}
</style>
